import java.util.Queue;


public class PrinterGroup {

	private class NodeJob{
		int origTime;
		
		private NodeJob(int origTime){
			this.origTime=origTime;
		}
	}
	
	private Queue<NodeJob> q;
	private double prob;
	private int simT;
	private int time;
	private int jobsDone;
	private double waitingT;
	private int waitingJobs;
	
	public PrinterGroup(double arrivalProb, double minServiceTime, double maxServiceTime, int simulationTime){
		if(arrivalProb<0||arrivalProb>1||minServiceTime<0||minServiceTime>maxServiceTime||maxServiceTime<0||simulationTime<0){
			throw new IllegalArgumentException();
		}
		jobsDone=0;
		time=0;
		waitingT=0;
		prob=arrivalProb;
		simT=simulationTime;
		waitingJobs=0;
		
		for(;time<simT;time++){
			newJob();
			doJobs(minServiceTime,maxServiceTime);
		}
		
		System.out.println(waitingJobs/simT);
		System.out.println(waitingT/simT);
	}
	
	private void doJobs(double min, double max) {
		Double rand=Math.random();
		if(min<=rand && max>=rand && q.size()>0){
			waitingT+=q.remove().origTime;
			jobsDone++;
			waitingJobs+=q.size();
		}
	}

	private void newJob(){
		Double rand=Math.random();
		if(rand>=prob){
			q.add(new NodeJob(time));
		}
	}
	
	
	
}
